<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .app {
        width: 100%;
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 30px;
        flex-direction: column;
      }
      .app button {
        font-size: 20px;
      }
    </style>
  </head>
  <body>
    <div class="app">
      <div id="showText"></div>
      <div id="receiveText"></div>
      <button id="showToast">展示toast</button>
      <button id="showBaidu">展示百度</button>
      <!-- <a href="http://wwww.baidu.com">百度</a> -->
    </div>
  </body>
  <script>
    // 接收 Flutter 返回的数据（需提前在 Flutter 端通过 runJavaScript 调用）
    window.receiveFlutterData = function (data) {
      //   console.log("收到 Flutter 数据:", data);
      document.getElementById("receiveText").innerHTML = JSON.stringify(data);
      //   alert("用户信息: " + JSON.stringify(data));
    };
    document.getElementById("showBaidu").addEventListener("click", function () {
      // 发送数据给 Flutter
      window.location.href = "https://www.baidu.com";
    });
    document.getElementById("showToast").addEventListener("click", function () {
      //   document.getElementById("showText").innerHTML = "toast展示中...";
      window.flutter.postMessage(
        JSON.stringify({
          name: "getUserInfo",
          data: {
            age: "31",
            name: "3113",
          },
        })
      );
    });
  </script>
</html>
